package Application发布事件;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableAsync;

@SpringBootApplication
@EnableAsync
public class DemoApplication implements CommandLineRunner {

    @Autowired
    private EventPublisherService eventPublisherService;

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }

    @Override
    public void run(String... args) {
        // 发布自定义事件
        eventPublisherService.publishEvent("Hello, ApplicationEventPublisher!");
    }
}
